/*
Thomas Sanchez Lengeling.
http://codigogenerativo.com/

KinectPV2, Kinect for Windows v2 library for processing

Mask test of the Body
*/

import KinectPV2.*;

KinectPV2 kinect;

boolean foundUsers = false;

void setup() {
  size(1024, 848); // 1024,424

  kinect = new KinectPV2(this);

  kinect.enableDepthImg(true);
  kinect.enableBodyTrackImg(true);

  kinect.init();
}

void draw() {
  background(0);

 //image(kinect.getDepthImage(), 0, 0); //prueba
  image(kinect.getBodyTrackImage(), 0, 0, 1024,848);

    //raw body data 0-6 users 255 nothing
  int [] rawData = kinect.getRawBodyTrack();

  foundUsers = false;
  for(int i = 0; i < rawData.length; i+=5){
    if(rawData[i] != 255){
     //found something
     foundUsers = true;
     break;
    }

  }

  //display the number of users detected 
  fill(255, 0, 0);
 // text(kinect.getNumOfUsers(), 50, 50);
  //text("Found User: "+foundUsers, 50, 70);
  //text(frameRate, 50, 90);

}

void mousePressed() {
  println(frameRate);
  ///saveFrame();
}